<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/mvc">
<head lang="en">
    <meta charset="UTF-8" />
    <title>待办状态修复</title>
    <script th:src="@{/js/jquery.js}"></script>
</head>
<body>
<h1 align="center">待办状态修复</h1>
<div>
    <input id="detailsHidenId" type="hidden">
    <input id="brandHidenId" type="hidden">
    <form name="examineInfo">
        <table align="center">
            <tr>
                <td>流水号:</td>
                <td><input type="text"  name="detailsId" style="width: 320px" /></td>
                <td>品牌ID:</td>
                <td><input type="text"  name="brandId" style="width: 320px" /></td>
                <td><input type="button" value="展示" onclick="return show()" /></td>
            </tr>
        </table>
        <!--<table align="center">-->
            <!--<tr>-->
                <!--<td>-->
                    <!--待办状态:-->
                <!--</td>-->
                <!--<td>-->
                    <!--<select name="isOk">-->
                        <!--<option value = "0">失败</option>-->
                        <!--<option value = "1">成功</option>-->
                        <!--<option value = "2">取消</option>-->
                        <!--<option value = "4">正在充值</option>-->
                        <!--<option value = "5">通知商服成功</option>-->
                    <!--</select>-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input type="button" value="修复待办状态" onclick="return update()" />-->
                <!--</td>-->
            <!--</tr>-->
        <!--</table>-->
    </form>
</div>
<div>
    <hr>
</div>
<div id="result">
</div>
</body>


<script type="text/javascript">
    function show() {
        var detailsId = examineInfo.detailsId.value;
        var brandId = examineInfo.brandId.value;
        $.post("/show",
            {"detailsId":detailsId,"brandId":brandId},
            function(data){
                var str = '';
                if(data.list!=null && data.list.length>0){
                    str = '<table align="center" border="1" cellpadding="5" cellspacing="0">';
                    str += '<tr align="center">' +
                                '<td>ID</td>' +
                                    '<td>流水号</td>' +
                                    '<td>品牌ID</td>' +
                                    '<td>设备ID</td>' +
                                    '<td>创建时间</td>' +
                                    '<td>待办状态</td>' +
                                    '<td>错误码</td>' +
                                    '<td>函数名称</td>' +
                                    '<td>操作人</td>' +
                                    '<td>更新时间</td>' +
                                    '<td>服务名称</td>' +
                                    '<td>充值金额</td>' +
                                    '<td>操作</td>'
                            '</tr>';
                    for (var i=0;i<data.list.length;i++){
                        var item = data.list[i];
                        str += '<tr align="center">';
                            str += '<td>'+item.id+'</td>';
                            str += '<td>'+item.detailsId+'</td>';
                            str += '<td>'+item.brandId+'</td>';
                            str += '<td>'+item.stayObj+'</td>';
                            str += '<td>'+item.createTime+'</td>';
                            str += '<td><select name="isOk" id="selectId'+item.detailsId+'">';
                                if(item.isOk == 0){
                                    str += '<option value = "0" selected="selected">失败</option>';
                                }else{
                                    str += '<option value = "0">失败</option>';
                                }
                                if(item.isOk == 1){
                                    str += '<option value = "1" selected="selected">成功</option>';
                                }else{
                                    str += '<option value = "1">成功</option>';
                                }
                                if(item.isOk == 2){
                                    str += '<option value = "2" selected="selected">取消</option>';
                                }else{
                                    str += '<option value = "2">取消</option>';
                                }
                                if(item.isOk == 4){
                                    str += '<option value = "4" selected="selected">正在充值</option>';
                                }else{
                                    str += '<option value = "4">正在充值</option>';
                                }
                                if(item.isOk == 5){
                                    str += '<option value = "5" selected="selected">通知商服成功</option>';
                                }else{
                                    str += '<option value = "5">通知商服成功</option>';
                                }
                            str += '</select></td>';
                            str += '<td>'+item.exMsg+'</td>';
                            str += '<td>'+item.funcName+'</td>';
                            str += '<td>'+item.operUser+'</td>';
                            str += '<td>'+item.updateTime+'</td>';
                            str += '<td>'+item.serviceName+'</td>';
                            str += '<td>'+item.param+'</td>';
                            str += "<td><input type=\"button\" value=\"修复\" onclick=\"update("
                                    +"'"
                                    +item.detailsId
                                    +"'"
                                    +")\"/></td>";
                        str += '</tr>';
                    }
                }else{
                    str = '<h3>无此待办记录！！！</h3>';
                }
                result.innerHTML = str;
            }
            );

    }

    function update(detailsId) {
        var isOk = document.getElementById('selectId'+detailsId).value;
        $.post("/update",
            {"detailsId":detailsId,"isOk":isOk},
            function(data){
                if(data!=null){
                    alert(data);
                    show();
                }else{
                    alert("网络错误！");
                    show();
                }
            }
            );
    }

</script>
</html>